<?
if (!defined('IN_RJ')) die("Error 404");
if($cmd[1]=="moviefull" && is_numeric($cmd[2])){
$movie_id=$cmd[2];
$DB->query("update ".$conf['prefix']."multimedia set multi_viewed=multi_viewed+1,multi_viewed_month=multi_viewed_month+1 where multi_id={$movie_id} and multi_type=2");
$query="select * from ".$conf['prefix']."multimedia where multi_id={$movie_id} and multi_type=2";
$rq = $DB->query($query);
$movie=$DB->fetch_row($rq);
        $title_movie = $func->unhtmlchars($movie["multi_name"]);
	     $title_movie_ascii = $func->unhtmlchars($movie["multi_name_ascii"]);		
		$ro= $tpl->get_tpl('fullscreen');
		$t['row'] = $tpl->get_block_from_str($ro,'epi_row',1);
			$html='';
			$sql_epi=$DB->query("SELECT * FROM {$conf['prefix']}media WHERE m_multimedia={$movie_id} ORDER BY CAST(m_title as SIGNED)");
			 $total_eps = $DB->num_rows($sql_epi);
			 if($total_eps){
			$i = 0;
			$overflow=($total_eps>30)?'height:300px; overflow:auto;':'';
				while($epi=$DB->fetch_row($sql_epi)){
					$i++;
					$arr_epi[$i]['id']=$epi['m_id'];
					$arr_epi[$i]['title']=$epi['m_title'];
				  $tr = (fmod($i,5) == 1)?'<tr></tr>':'';	
					$html .= $tpl->assign_vars($t['row'],
						array(
							'epi.NAME'		=> $lang['part']." ".$epi['m_title'],
							'epi.STT'		=> $i,
							'epi.TOTAL'		=> $total_eps,
							'epi.ID'		=> $epi['m_id'],
							'movie.ID'	=> $movie_id,	
							'epi.TR'		=> $tr,
							
						)
					);
					
				}
	
			if(!$conf['must_login_to_download']){
				$download_block='<div style="width:240px; height:64px;" align="center">
						<form method="post" name="get_download_epi" onsubmit="get_download(this,\'epi\'); return false;">
						<b>'.$lang['choose_epi_down'].' </b><br />
						<select id="select_down" name="select_down">';
				foreach($arr_epi as $epi_d){
						$download_block.= "<option value='".$epi_d['id']."'>".$lang['part']." ".$epi_d['title']."</option>";
					 }
				$download_block.='</select>
						<input type="hidden" value="'.$func->encode_down($movie_id).'" id="id_down" name="id_down" />
						<input type="hidden" value="'.$movie_id.'" id="movie_id"  name="movie_id" />
						<input type="submit" value="Download" />
						</form>
						</div>'; 
			}
			else $download_block=$lang['must_login_to_download'];
		}
		else{
			$download_block='';
			$html="<center><font color=blue>".$lang['updating']."</font></center><br>";
		}
		
			$ro = $tpl->assign_blocks_content($ro,array(
				'list_epi'	=> $html,
				'download' => $download_block,
				)
			);
			$ro = $tpl->assign_vars($ro,
				array(
					'movie.ID'	=> $movie_id,
					'movie.OVERFLOW'  =>$overflow,
				)
			);

	$js_block = "<script>var web_url=\"{$conf['web_url']}\";</script>\n";
	$js_block .= "<script src='{$conf['web_url']}/js/js.js'></script><script src='{$conf['web_url']}/js/him.js'></script>";
			$ro = $tpl->assign_blocks_content($ro,array(
			'js'		=>	$js_block,
		)
	);
	$title_index='';
	if(!empty($title_movie) && !empty($title_movie_ascii))
		$title_index=$title_movie." | ".$title_movie_ascii." | ";
	$ro = $tpl->assign_vars($ro,array(
			'TITLE_WEB_BAR' => $title_index,
		)
	);
	echo $tpl->parse_tpl($ro);

}
?>